<template>
   
<!-- 评论的 -->
  <div class="list-group-item" style="border: 0px;margin-top:20px;">

     

      <div class="media text-left" v-for="item in comment">
          <a class="media-left" href="#">
              <img class="media-object" v-bind:src="item.user[0].tou" width="50px;" alt="媒体对象">
          </a>
          <div class="media-body">
              <h4 style="color:  #09e564" class="media-heading">{{item.user[0].username}}</h4>
              {{item.content}}
          </div>
      </div>



      <!--评论的框-->
      <div class="form-group" style="margin-top: 30px;">
          <label style="font-size: 19px;" class="col-sm-2 control-label">评论</label>
          <div class="col-sm-10">
              <input type="text" class="form-control" v-model="context" placeholder="请输入评论内容" required max="30" maxlength="30">
              <button style="float: right;margin-top: 10px;" class="btn btn-info" @click="wl_go()">提交</button>
          </div>

      </div>
                    <br>
                    <span style="font-size: 20px"><a href=""></a> </span><span></span>
                    <p style="padding-top: 20px"  ></p>
                    <br>




                </div>
</template>
<style>


</style>
<script>
 import conf from '../layout/conf.vue';//引用模块进来
    export default {

        
        mounted() {
                
                    console.log("加载评论的模块!");
                    this.id=this.$route.params.id;
                 this.axios.get(this.geturl+"id="+this.id).then(response=>{
                    console.log(response);
                    // return;
                 this.comment=response['data']['comment'];

                  })
           

        },
        data(){
            return {
                comment:[],
                context:"",
                geturl:conf.url+"/index/comment/index/",
                posturl:conf.url+"/index/comment/add/",
                id:"",

            }


        },
        methods:{

            wl_go(){
               
               var params = new URLSearchParams();
                params.append('post_id', this.id);
                params.append('content', this.context);

                var access_token=this.GetCookie("wlphp.cn");
                params.append('token', access_token);
                    



                   this.axios.post(this.posturl,params).then(response=>{
                    this.context="";

                console.log(response);
                if(response['data']['status']=="error"){
                    

                    this.$layer.msg("先登陆!");
                    
                              

                }else{
                    this.message("ok","评论成功!");
                      this.axios.get(this.geturl+"id="+this.id).then(response=>{
                
                            this.comment=response['data']['comment'];

                      })   
                }
               

            })
                
            }
        }


    }
</script>
